package entity;

public class Student extends Person {
    private Course selectedCourse;

    // 子类构造方法
    public Student(String id, String name, String gender) {
        super(id, name, gender);
        this.selectedCourse = null;
    }

    // 学生选课方法
    public void selectCourse(Course course) {
        if (this.selectedCourse != null) {
            System.out.println(name + "已经选择了课程: " + selectedCourse.getCourseName());
            return;
        }
        this.selectedCourse = course;
        System.out.println(name + "成功选择了课程: " + course.getCourseName());
    }

    // 学生退课方法
    public void dropCourse() {
        if (this.selectedCourse != null) {
            System.out.println(name + "退选了课程: " + selectedCourse.getCourseName());
            this.selectedCourse = null;
        } else {
            System.out.println(name + "当前没有选择任何课程");
        }
    }

    // 打印学生课表
    public void printCourseSchedule() {
        System.out.println("=== " + name + "的课表 ===");
        System.out.println("编号: " + id);
        if (selectedCourse != null) {
            System.out.println("课程名称: " + selectedCourse.getCourseName());
            System.out.println("上课地点: " + selectedCourse.getLocation());
            System.out.println("上课时间: " + selectedCourse.getTime());
            System.out.println("授课教师: " + selectedCourse.getTeacher().getName());
        } else {
            System.out.println("暂无课程");
        }
        System.out.println("=====================");
    }

    public Course getSelectedCourse() { return selectedCourse; }
}